﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 智慧大棚课件
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = $"select id,time,Hum,Tem,O2,wind from DataTable where time >= '{dateTimePicker1.Value}' and time < '{dateTimePicker2.Value}'";

            SqlDataReader reader = SqlHelper.SelectResult(sql);

            List<Data> list = new List<Data>();
 
            while (reader.Read())
            {
                // 读取数据
                DateTime time = Convert.ToDateTime( reader["time"]);


                // 温度 湿度。。。

                list.Add(new Data { Time = time });

            }
            
            dataGridView1.DataSource = list;

        }
    }
}
